library(here)

load(here("Analysis", "analysis_anyDA_Diversity_new.rda"), verbose = TRUE)

pdf(file = here("Figures_Tables", "coefplot_anyDA_Diversity_new.pdf"), width = 8, height = 2.5)
par(oma = rep(0, 4), mar = c(6, 2, 2, 1), mgp = c(4, .5, 0), xpd = NA)
oldmai <- par("mai")
newmai <- oldmai
newmai[2] <- max(strwidth(row.names(res[1:2, ]), units = "inches")) + .1
par(mai = newmai)
nmods <- nrow(res[1:2, ])
theylim <- range(c(0, as.vector(res[1:2, ])[is.finite(as.vector(res[1:2, ]))]))
plot(theylim, c(1, nmods),
  type = "n", axes = FALSE, ylab = "",
  xlab = "Effect of 1 Unit Difference in Diversity Index of Perceptions of\n Visible Minorities in Local Community \n (+/- 95% CI)"
)
segments(res[1:2, "ci1"], 1:nmods, res[1:2, "ci2"], 1:nmods)
points(res[1:2, "Estimate"], 1:nmods, pch = 19)
abline(v = 0, lwd = .5, col = gray(.7))
axis(1, line = .5)
axis(2, at = 1:nmods, labels = row.names(res[1:2, ]), las = 1)
par(mai = oldmai)
dev.off()

system("touch Figures_Tables/figures_anyDA_Diversity_new.done")
